﻿@model IEnumerable<OrderSystem.Models.Users>
@{
    ViewBag.Title = "User List";
}
<script language="javascript" type="text/javascript">
    function Reset()
    {
                        document.location.href = '@Url.Action("Index", "OrderSystemUser")';
    }
</script>



<p>This page is apained for creating new and managing existing users</p>
<h4>@Html.ActionLink("Create New User","Register")</h4>
<p></p>
<p>Number of Found Users: @ViewData["CountOfUsers"].ToString()</p>
@using (Html.BeginForm())
{
<fieldset>
<legend>Search by</legend>
<p>Field Filter</p>
<select id="UserInfo" name="UserInfo">
  <option>UserName</option>
  <option>FirstName</option>
  <option>LastName</option>
  <option>Mail</option>
  <option>Role</option>
  <option>Region</option>
</select>

<select id="FiltrationOption" name="FiltrationOption">
<option>Contain's</option>
<option>Start's with</option>
<option>End's with</option>
</select>

<input type=text id="FiltrationText" name="FiltrationText" />

<p></p>
<input type=submit value="Search" />
<button type=reset value="reset" onclick="Reset()">Reset</button>
</fieldset>
}
<p></p>
<div>
@{
    //TODO Get Users List From Model And Render Grid
    WebGrid usersGrid = new WebGrid(Model,canPage:true,canSort: true, rowsPerPage: 10);
    
 }
@usersGrid.GetHtml(tableStyle: "webgrid",
                              headerStyle: "webgrid-header",
                              footerStyle: "webgrid-footer",
                              alternatingRowStyle: "webgrid-alternating-row",
                              selectedRowStyle: "webgrid-selected-row",
                              rowStyle: "webgrid-row-style",
                              mode: WebGridPagerModes.All, 
                              firstText: "First", 
                              lastText: "Last", 
                              previousText: "Previous", 
                              nextText: "Next", 
                              numericLinksCount: 5,
                              columns: 
                              usersGrid.Columns(usersGrid.Column("Login", "User Name"), 
                              usersGrid.Column("UserFName", "First Name"), 
                              usersGrid.Column("UserLName", "Last Name"), 
                              usersGrid.Column("Role"), 
                              usersGrid.Column("Mail"), 
                              usersGrid.Column("Region"),
                              usersGrid.Column("Edit", canSort: false, format: (item) => Html.ActionLink("Edit", "Edit", new { id = item.UserID }, new { @class = "webridUserEdit" })),
                              usersGrid.Column("Remove", canSort: false, format: (item) => Html.ActionLink("Delete", "Delete", new { id = item.UserID }, new { @class = "webridUserRemove" })),
                              usersGrid.Column("Duplicate", canSort: false, format: (item) => Html.ActionLink("Duplicate", "Duplicate", new { id = item.UserID }, new { @class = "webridUserDuplicate" }))))

</div>